﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace sabConn
{
    public class Job
    {
        //XML Values
        private int _index;
        public int Index { get { return _index; } set { _index = value; } }
        private string _filename;
        public string Filename { get { return _filename; } set { _filename = value; } }
        private Priority _priority;
        public Priority priority { get { return _priority; } set { _priority = value; } }
        private TimeSpan _timeleft;
        public TimeSpan timeleft { get { return _timeleft; } set { _timeleft = value; } }
        private string _age;
        public string age { get { return _age; } set { _age = value; } }
        private double _mb;
        public double mb { get { return _mb; } set { _mb = value; } }
        private double _mbleft;
        public double mbleft { get { return _mbleft; } set { _mbleft = value; } }
        private string _status;
        public string status { get { return _status; } set { _status = value; } }
        private string _category;
        public string category { get { return _category; } set { _category = value; } }
        private double _percentage;
        public double percentage { get { return _percentage; } set { _percentage = value; } }
        private string _nzo_id;
        public string nzo_id { get { return _nzo_id; } set { _nzo_id = value; } }

        private Queue m_parent;

        public enum Priority
        {
            Default,
            Low,
            Normal,
            High
        }

        public Job(string status, int index, string eta, TimeSpan timeleft, string age,
                   double mbleft, double mb, string filename, Priority priority,
                   string category, double percentage, string nzo_id, Queue mpar)
        {
            _status = status;
            _index = index;
            _timeleft = timeleft;
            _age = age;
            _mbleft = mbleft;
            _mb = mb;
            _filename = filename;
            _priority = priority;
            _category = category;
            _percentage = percentage;
            _nzo_id = nzo_id;
            m_parent = mpar;
        }

        public void delete()
        {
            string cmdstring;
            cmdstring = m_parent.m_parent.serverstring + "/sabnzbd/api?mode=queue&name=delete&value=" + nzo_id + "&apikey=" + m_parent.m_parent.apikey;
            m_parent.m_parent.requestpage(cmdstring);
        }

        public void moveto(int indexpos)
        {
            string cmdstring;
            cmdstring = m_parent.m_parent.serverstring + "/sabnzbd/api?mode=switch&value=" + nzo_id + "&value2=0&apikey=" + m_parent.m_parent.apikey;
            m_parent.m_parent.requestpage(cmdstring);
        }


    }
}
